package ua.yandex.threadpool;

import java.util.concurrent.BlockingQueue;

public class PoolThread extends Thread {

    private BlockingQueue taskQueue = null;
    private volatile boolean isStopped = false;

    public PoolThread(BlockingQueue queue) {
        this.taskQueue = queue;
    }

    public void run() {
        while (!isStopped()) {
            try {
                Runnable runnable = (Runnable) taskQueue.take();
                runnable.run();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public void stopThread() {
        isStopped = true;
    }

    public boolean isStopped() {
        return isStopped;
    }
}
